//
//  MyCustonNavController.m
//  TestDemo
//
//  Created by 张润东 on 2021/8/23.
//

#import "MyCustonNavController.h"

@interface MyCustonNavController ()

@end

@implementation MyCustonNavController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}
//自定义返回前处理：
-(void)backBtnClick{
    NSLog(@"自定义点击回退按钮,在此实现拦截方法,如果不实现回退，那就完犊子咯");
    [self popViewControllerAnimated:YES];
}

//默认全局样式
-(void)navDefaultSetting{
    self.navigationBar.barStyle = UIBarStyleBlack;//状态栏黑色   UIBarStyleBlack:状态栏白色
    [self.navigationBar setShadowImage:[UIImage new]];//底部细线消失术
    [self.navigationBar setTranslucent:NO];//是否半透明标识
    [self.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[UIFont systemFontOfSize:19]}];//title文字颜色与大小
    [self.navigationBar setBackgroundImage:[self imageWithColor:[UIColor systemRedColor]] forBarMetrics:UIBarMetricsDefault];//背景颜色
    self.automaticallyAdjustsScrollViewInsets = NO;
}


- (UIImage*)imageWithColor:(UIColor *)color{
    CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, color.CGColor);
    CGContextFillRect(context, rect);
    UIImage* image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    NSData* imageData = UIImageJPEGRepresentation(image, 1.0f);
    image = [UIImage imageWithData:imageData];
    return image;
}


@end
